<template>
    <div class="app-container calendar-list-container">

        <!-- 查询和其他操作 -->
        <div class="filter-container">
          <el-select placeholder="类型" v-model="listQuery.type" clearable="">
            <el-option label="点餐" value="1"></el-option>
            <el-option label="外卖" value="2"></el-option>
          </el-select>
          <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">查找</el-button>
        </div>

        <!-- 查询结果 -->
        <el-table size="small" :data="list" v-loading="listLoading" element-loading-text="正在查询中。。。" border fit highlight-current-row>

          <el-table-column align="center" min-width="120px" label="平台编号" prop="platformId">
          </el-table-column>
          <el-table-column align="center" min-width="120px" label="商户账号" prop="merId">
          </el-table-column>
          <el-table-column align="center" min-width="120px" label="用户账号" prop="perId">
          </el-table-column>       
          <el-table-column align="center" min-width="120px" label="餐桌编号" prop="tableId">
          </el-table-column>       
          <el-table-column align="center" min-width="120px" label="菜品编号" prop="dishesId">
          </el-table-column>   
          <el-table-column align="center" min-width="120px" label="菜品名称" prop="dishesName">
          </el-table-column>   
          <el-table-column align="center" min-width="80px" label="数量" prop="dishesNum">
          </el-table-column>       
          <el-table-column align="center" min-width="80px" label="总价" prop="dishesPrice">
          </el-table-column>     
          <el-table-column align="center" min-width="80px" label="状态" prop="status">
            <template slot-scope="scope">
              <span v-if="scope.row.status == '1'">已选择</span>
              <span v-if="scope.row.status == '2'">已提交</span>
              <span v-if="scope.row.status == '3'">已支付</span>
            </template>
          </el-table-column>      
          <el-table-column align="center" min-width="80px" label="类型" prop="type">
            <template slot-scope="scope">
              <span v-if="scope.row.type == '1'">点餐</span>
              <span v-if="scope.row.type == '2'">外卖</span>
            </template>
          </el-table-column>      

        </el-table>

        <!-- 分页 -->
        <div class="pagination-container">
        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="listQuery.page"
            :page-sizes="[10,20,30,50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
        </el-pagination>
        </div>

    </div>
</template>

<script>
import waves from '@/directive/waves' // 水波纹指令
import { listShoppingCartInfo } from '@/api/cms/restaurant/shoppingCart'

export default {
  name: 'auction',
  directives: {
    waves
  },
  data() {
    return {
      listQuery: {
        page: 1,
        limit: 20,
        type: ''
      },
      list: [],
      total: 0,
      listLoading: false,
      downloadLoading: false
    }
  },
  created() {
    this.getList()
  },
  methods: {
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    handleSizeChange(val) {
      this.listQuery.limit = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.listQuery.page = val
      this.getList()
    },
    getList() {
      this.listLoading = true
      listShoppingCartInfo(this.listQuery).then(response => {
        console.log(response)
        this.list = response.data.rows
        this.total = response.data.total
        this.listLoading = false
      }).catch(() => {
        this.list = []
        this.total = 0
        this.listLoading = false
      })
    }
  }
}
</script>

<style>

</style>


